﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for Asset
/// </summary>
public class Asset
{
	private const string STORED_PROCEDURE = "Asset_Get";
	DatabaseManager db;
	MySqlDataReader reader;

  public int Id { get; set; }
	public int Year { get; set; }
	public int LongTermAssets { get; set; }
	public int ShortTermAssets { get; set; }
  public int TotalAssets { get; set; }

	public Asset()
	{
		db = new DatabaseManager();
	}

	public void Load(string id, int year)
	{
		db.AddParameter("@id", id);
    db.AddParameter("@year", year);
		using (reader = db.ExecuteStoredProcedure(STORED_PROCEDURE))
		{
			while (reader.Read())
			{
				Id = Convert.ToInt32(reader["id"]);
        Year = Convert.ToInt32(reader["year"]);
        LongTermAssets = Convert.ToInt32(reader["long_term_assets"]);
        ShortTermAssets = Convert.ToInt32(reader["short_term_assets"]);
        TotalAssets = Convert.ToInt32(reader["total_assets"]);
			}
		}
	}
}